<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/codeblog/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/codeblog/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/codeblog/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/codeblog/images/logo.svg" color="#222">

<link rel="stylesheet" href="/codeblog/css/main.css">


<link rel="stylesheet" href="/codeblog/lib/font-awesome/css/all.min.css">
  <link rel="stylesheet" href="/codeblog/lib/pace/pace-theme-minimal.min.css">
  <script src="/codeblog/lib/pace/pace.min.js"></script>

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"skycoin.gitee.io","root":"/codeblog/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":true,"scrollpercent":true},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":"valine","storage":true,"lazyload":false,"nav":null,"activeClass":"valine"},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="[toc] 1.语法1.1 区分大小写 ​ ECMAScript 中的一切（变量、函数名和操作符）都区分大小写 1.2 标识符 ​ 指的就是变量、函数、属性的名字。或者函数的参数。标识符可以是按照下列格式规则组合起来的一或多个字符  第一个字符必须是一个字母、下划线或一个美元符 fv 号  其他字符可以是字母、下划线、美元符号或数字  标识符中字母也可以包含扩展的 ASCII 或 Unicode">
<meta property="og:type" content="article">
<meta property="og:title" content="Javascript基础（二）：javascript基本概念">
<meta property="og:url" content="http://skycoin.gitee.io/codeblog/2021/02/27/%E5%9F%BA%E6%9C%AC%E6%A6%82%E5%BF%B5/index.html">
<meta property="og:site_name" content="若水的前端博客">
<meta property="og:description" content="[toc] 1.语法1.1 区分大小写 ​ ECMAScript 中的一切（变量、函数名和操作符）都区分大小写 1.2 标识符 ​ 指的就是变量、函数、属性的名字。或者函数的参数。标识符可以是按照下列格式规则组合起来的一或多个字符  第一个字符必须是一个字母、下划线或一个美元符 fv 号  其他字符可以是字母、下划线、美元符号或数字  标识符中字母也可以包含扩展的 ASCII 或 Unicode">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2021-02-27T02:14:52.000Z">
<meta property="article:modified_time" content="2021-04-15T01:24:09.764Z">
<meta property="article:author" content="若说">
<meta property="article:tag" content="前端">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://skycoin.gitee.io/codeblog/2021/02/27/%E5%9F%BA%E6%9C%AC%E6%A6%82%E5%BF%B5/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>Javascript基础（二）：javascript基本概念 | 若水的前端博客</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

<link rel="alternate" href="/codeblog/atom.xml" title="若水的前端博客" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>
    <a target="_blank" rel="noopener" href="https://your-url" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#70B7FD; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/codeblog/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">若水的前端博客</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">最优秀的模式往往是最简单的东西</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/codeblog/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/codeblog/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/codeblog/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/codeblog/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://skycoin.gitee.io/codeblog/2021/02/27/%E5%9F%BA%E6%9C%AC%E6%A6%82%E5%BF%B5/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=4083356047,3551369852&fm=26&gp=0.jpg">
      <meta itemprop="name" content="若说">
      <meta itemprop="description" content="立志完成前端知识体系的架构">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="若水的前端博客">
    </span>
      <header class="post-header">
      
        <i class="fa fa-thumb-tack"></i>
        <font color=7D26CD>置顶</font>
      
        <h1 class="post-title" itemprop="name headline">
          Javascript基础（二）：javascript基本概念
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-02-27 10:14:52" itemprop="dateCreated datePublished" datetime="2021-02-27T10:14:52+08:00">2021-02-27</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-04-15 09:24:09" itemprop="dateModified" datetime="2021-04-15T09:24:09+08:00">2021-04-15</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/codeblog/categories/%E5%89%8D%E7%AB%AF%E6%A1%86%E6%9E%B6/" itemprop="url" rel="index"><span itemprop="name">前端框架</span></a>
                </span>
            </span>

          
            <span id="/codeblog/2021/02/27/%E5%9F%BA%E6%9C%AC%E6%A6%82%E5%BF%B5/" class="post-meta-item leancloud_visitors" data-flag-title="Javascript基础（二）：javascript基本概念" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/codeblog/2021/02/27/%E5%9F%BA%E6%9C%AC%E6%A6%82%E5%BF%B5/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/codeblog/2021/02/27/%E5%9F%BA%E6%9C%AC%E6%A6%82%E5%BF%B5/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>[toc]</p>
<h2 id="1-语法"><a href="#1-语法" class="headerlink" title="1.语法"></a>1.语法</h2><p>1.1 区分大小写</p>
<p>​ ECMAScript 中的一切（变量、函数名和操作符）都区分大小写</p>
<p>1.2 标识符</p>
<p>​ 指的就是变量、函数、属性的名字。或者函数的参数。标识符可以是按照下列格式规则组合起来的一或多个字符</p>
<ul>
<li><p>第一个字符必须是一个字母、下划线或一个美元符 fv 号</p>
</li>
<li><p>其他字符可以是字母、下划线、美元符号或数字</p>
</li>
<li><p>标识符中字母也可以包含扩展的 ASCII 或 Unicode 字母字符</p>
</li>
<li><p>惯例，ECAMAScript 标识符采用驼峰大小写格式，也就是第一个字母小写，剩下的每个单词的首字母大写</p>
</li>
<li><p>不能把关键字、保留字、true、false 或 null 用作标识符</p>
<p>1.3 注释</p>
</li>
<li><p>单行注释 //</p>
</li>
<li><p>多行注释 /* */</p>
<p>1.4 严格模式</p>
</li>
</ul>
<p>为 js 定义了一种不同的解析与执行模型。在严格模式下，ECMAScript 中一些不确定的行为将得到处理，而且对某些不安全的操作也会抛出错误。因此要在整个脚本中启用严格模式。</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&quot;use strict&quot;</span>;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>它是一个编译指示，用于告诉支持 js 引擎切换到严格模式</p>
<p>1.5 语句</p>
<p>​ ECMAScript 中的语句以一个分号结尾；如果省略分号，则由解析器确定语句的结尾</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> sum = a + b;</span><br><span class="line"><span class="keyword">var</span> diff = a - b;</span><br></pre></td></tr></table></figure>

<p>虽然语句结尾的分号不是必须的，但是建议还是不要省略，因为加上这个分号可以避免很多的错误</p>
<p>虽然条件控制语句只在执行多条语句的情况下才要求使用代码块，但最佳实践是-即使代码块中只有一条语句，也要使用代码块</p>
<p>1.6 关键字和保留字</p>
<p>ECMA-262 描述了一组具有特定用途的关键字，这些关键字可用于表示控制语句的开始或结束，或者用于执行特定操作。关键字是语言保留的，不能用作标识符，下面是 ECMAScript 全部的关键字</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">break</span> <span class="keyword">do</span> <span class="keyword">instanceof</span> <span class="keyword">typeof</span> <span class="keyword">case</span> <span class="keyword">else</span> <span class="keyword">new</span> <span class="keyword">var</span> <span class="keyword">catch</span> <span class="keyword">finally</span> <span class="keyword">return</span> <span class="keyword">void</span> <span class="keyword">continue</span> <span class="keyword">for</span> <span class="keyword">switch</span> <span class="keyword">while</span> <span class="keyword">debugger</span>* <span class="function"><span class="keyword">function</span> <span class="title">this</span> <span class="title">with</span> <span class="title">default</span> <span class="title">if</span> <span class="title">throw</span> <span class="title">delete</span> <span class="title">in</span> <span class="title">try</span></span></span><br></pre></td></tr></table></figure>

<p>第 5 版在非严格模式下运行时的保留字缩减为</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">enum</span> <span class="keyword">extends</span> <span class="title">super</span> <span class="title">const</span> <span class="title">export</span> <span class="title">import</span></span></span><br></pre></td></tr></table></figure>

<p>在严格模式下施加了限制</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">implements package public interface private <span class="keyword">static</span> <span class="keyword">let</span> protected <span class="keyword">yield</span></span><br></pre></td></tr></table></figure>

<p>1.7 变量</p>
<p>ECMAScript 的变量是松散类型的，也就是可以用来保存任何类型的数据。换句话说，每个变量仅仅是一个用于保存值的占位符而已。</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> message;</span><br></pre></td></tr></table></figure>

<p>该变量可以用来保存任何值</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">test</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">  <span class="keyword">var</span> message = <span class="string">&quot;hi&quot;</span>; <span class="comment">//局部变量</span></span><br><span class="line">&#125;</span><br><span class="line">test();</span><br><span class="line">alert(message);</span><br></pre></td></tr></table></figure>

<p>使用一条语句定义多个变量</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> message = <span class="string">&quot;hi&quot;</span>,</span><br><span class="line">  found = fasle,</span><br><span class="line">  age = <span class="number">29</span>; <span class="comment">//提高可读性</span></span><br></pre></td></tr></table></figure>

<p>在严格模式下，不能定义名为 eval 或 arguments 的变量，否则会导致语法错误</p>
<ul>
<li>变量命名必须是以字母或是下标符号”_“或者”$”为开头</li>
<li>变量名长度不能超过 255 个字符</li>
<li>变量名中不允许使用空格，首个字母不能为数组</li>
<li>不用使用脚本语言中保留的关键字及保留符号作为变量名</li>
<li>变量名区分大小写</li>
</ul>
<h2 id="2-数据类型"><a href="#2-数据类型" class="headerlink" title="2.数据类型"></a>2.数据类型</h2><p>2.1 undefined 类型</p>
<p>只有一个值，即特殊的 undefined。在使用 var 声明变量但未对齐加以初始化时，这个变量的值就是 undefined</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> message;</span><br><span class="line">message == <span class="literal">undefined</span>; <span class="comment">//true. 未经初始化的值默认就是undefined</span></span><br></pre></td></tr></table></figure>

<p>typeof 对未初始化和未声明变量的返回都是 undefined 值</p>
<p>注意：没有必要把一个变量的值显示的设置成 undefined</p>
<p>2.2 Null 类型</p>
<p>Null 可以作为一个空对象的指针</p>
<p>undefined 的值是派生自 null 值的。</p>
<p>只要意在保存对象的变量还没有真正的保存对象，就应该明确地让该变量保存 null 值</p>
<p>2.3boolean</p>
<p>各种类型转化的规则</p>
<table>
<thead>
<tr>
<th>数据类型</th>
<th>转换为 true 的值</th>
<th>转换为 false 的值</th>
</tr>
</thead>
<tbody><tr>
<td>Boolean</td>
<td>True</td>
<td>False</td>
</tr>
<tr>
<td>String</td>
<td>任何非空字符串</td>
<td>空字符串</td>
</tr>
<tr>
<td>Number</td>
<td>任何非零数字值</td>
<td>0 和 NaN</td>
</tr>
<tr>
<td>Object</td>
<td>任何对象</td>
<td>Null</td>
</tr>
<tr>
<td>Undefined</td>
<td>/</td>
<td>false</td>
</tr>
</tbody></table>
<p>这种转换可以理解 if 语句</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> message = <span class="string">&#x27;hello world&#x27;</span>;</span><br><span class="line"><span class="keyword">if</span>(message)&#123;</span><br><span class="line">  alert(<span class="string">&#x27;value is true&#x27;</span>)</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>2.4Number</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> intNum = <span class="number">55</span>; <span class="comment">// 整数</span></span><br><span class="line"><span class="comment">// 8进制 第一位必须是 0 ，八进制数字序列（0 - 7)</span></span><br><span class="line"><span class="comment">// 八进制字面量在严格模式下是无效的，会导致js引擎错误</span></span><br><span class="line"><span class="keyword">var</span> oct = <span class="number">070</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">//16进制 前两位必须是0x 后跟(0-9,以及A-F)</span></span><br><span class="line"><span class="keyword">var</span> hex = <span class="number">0x1f</span>;</span><br></pre></td></tr></table></figure>

<p>在进行算术计算时，所有的八进制和十六进制表示的数值最终都将会被转换成十进制</p>
<p>2.4.1 浮点数值</p>
<p>该数值中必须包含一个小数点，并且小数点后面必须有一位数字</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> floatNum = <span class="number">1.1</span>;</span><br></pre></td></tr></table></figure>

<p>由于保存浮点数值需要的内存空间时保存整数值的两倍，因此 ECMAScript 会不失时机地将浮点数值转换为整数值。如果浮点数值本身就是一个整数，那么也会转换成为整数</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> floatNum = <span class="number">1</span>;</span><br><span class="line"><span class="keyword">var</span> floatNum1 = <span class="number">10.0</span>;</span><br></pre></td></tr></table></figure>

<p>浮点数的最高精度时 17 位小数</p>
<p>2.4.2 NaN</p>
<p>Not a Number：非数值，这个数值用于表示一个本来要返回数值的操作数未返回数值的情况</p>
<p>NaN 的两个特点：</p>
<ul>
<li>任何涉及 NaN 的操作都会返回 NaN</li>
<li>NaN 与任何值都不相等</li>
</ul>
<p>ECMAScript 定义了 isNaN()函数，接收一个参数，参数可以时任何类型，不是数值的的值会直接转换为数值。</p>
<p>数值转换函数</p>
<ul>
<li>Number()</li>
<li>parseInt()</li>
<li>parseFloat()</li>
</ul>
<p>第一个函数，转型函数 Number 可以使用任何数据类型，另外两个函数专门用于把字符串转换成数值。</p>
<p>如果是 null，则返回 0</p>
<p>Undefined 返回 NaN</p>
<p>parseInt()解析八进制</p>
<p>多数情况下第二个参数也十分的重要</p>
<p>2.4.3 String 类型</p>
<p>字符字面量</p>
<p>String 数据类型包含一些特殊的字符字面量，也叫转译序列</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">\n      换行    newLine</span><br><span class="line">\t.     制表    table making</span><br><span class="line">\b.     退格    backsapce</span><br><span class="line">\r。    回车    resolve</span><br><span class="line">\f。    进纸</span><br><span class="line">\\.     斜杠</span><br></pre></td></tr></table></figure>

<p>字符串的特点</p>
<p>字符串一旦创建,它们的值就不能改变</p>
<p>数值、布尔值、对象和字符串值（每个字符串也都有一个 toString()方法，该方法返回字符串的一个副本)都有 toString()方法。null 和 undefined 没有</p>
<p>通过传递基数，toString（）可以输出以二进制</p>
<p>Object 类型</p>
<p>ECMAScript 中的对象其实就是一组数据和功能的集合。对象可以通过执行 new 操作符后跟要创建的对象类型的名称来创建。而创建 Object 实例并为其添加属性和方法，就可以创建自定义对象</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> o = <span class="keyword">new</span> <span class="built_in">Object</span>(); <span class="comment">// 如果不给构造函数传递参数，则可以省略后面的那一对括号。</span></span><br></pre></td></tr></table></figure>

<p>object 类型所具有的任何属性和方法同样也存在与更具体的对象中<br>每个实例都具有下列的属性和方法</p>
<ul>
<li>constructor:保存当前用于创建当前对象的函数。对于前面李子来说，构造函数(constructor）就是 Object</li>
<li>hasOwnProperty：用于检查给定的属性在当前对象实例中是否存在。</li>
<li>isPrototypeOf(object)：用于检查传入对象是否是当前对象的原型</li>
<li>propertylsEnumerable(propertyName):用于检查给定的属性是否能够使用 for..in 语句来枚举</li>
<li>toLocalString():返回对象的字符串表示，该字符串与执行环境的地区对应</li>
<li>toString（）:返回对象的字符串的表示</li>
<li>valueOf():返回对象的字符串、数值或布尔值</li>
</ul>
<p>隐式转换</p>
<p>首先要清楚 js 中存在两个方法 valueof 和 testing，它们存在于最顶层的原型 Object.prototype 上，也就是说我们可以通过原型链访问到这两个方法，它们适用于 ToPrimitive 也就是转换为原始值。valueof 函数返回的是本身（基础类型则是原始值，引用类型则是 this);toString 函数在基础类型中返回的是字符串化的原始值，在引用类型中则是返回当前类型。值得注意的是，js 对 valueof 和 tostring 进行了不同的实现</p>
<p>在进行隐式转换的时，总会先调用 valueof，如果返回值不是原始值的话，又会继续调用 toString 方法。对于非引用类型，valueOf 返回的则是原始值，引用类型则是返回它本身。</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> obj = &#123;</span><br><span class="line">  <span class="function"><span class="title">valueOf</span>(<span class="params"></span>)</span> &#123;</span><br><span class="line">    <span class="keyword">return</span> <span class="string">&quot;valueOf&quot;</span>;</span><br><span class="line">  &#125;,</span><br><span class="line">  <span class="function"><span class="title">toString</span>(<span class="params"></span>)</span> &#123;</span><br><span class="line">    <span class="keyword">return</span> <span class="string">&quot;toString&quot;</span>;</span><br><span class="line">  &#125;,</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>

<p>部分内置对象实现 valueof 和 tostring 的方法</p>
<table>
<thead>
<tr>
<th>类型</th>
<th>ValueOf</th>
<th>toString</th>
</tr>
</thead>
<tbody><tr>
<td>Number(123)</td>
<td>123</td>
<td>‘123’</td>
</tr>
<tr>
<td>String(‘abc123’)</td>
<td>‘abc123’</td>
<td>‘ab123’</td>
</tr>
<tr>
<td>Boolean(‘666’)</td>
<td>True</td>
<td>True</td>
</tr>
<tr>
<td>Date()</td>
<td>时间戳</td>
<td>日期字符串</td>
</tr>
<tr>
<td>Array([1,2,3])</td>
<td>This</td>
<td>‘1,2,3’(相当于调用 join(‘,’))</td>
</tr>
<tr>
<td>Object({})</td>
<td>This</td>
<td>‘[object object]’</td>
</tr>
<tr>
<td>Function(()=&gt;{})</td>
<td>This</td>
<td>‘() =&gt; {}’</td>
</tr>
<tr>
<td>RegExp(‘1’)</td>
<td>This</td>
<td>‘/1/‘</td>
</tr>
</tbody></table>
<p>例子：</p>
<p><strong>例一</strong></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> result = <span class="number">100</span> + <span class="literal">true</span> + <span class="number">21.2</span> + <span class="literal">null</span> + <span class="literal">undefined</span> + <span class="string">&quot;tencent&quot;</span> + [] + <span class="number">9</span> + <span class="literal">false</span>;</span><br><span class="line"><span class="built_in">console</span>.log(result);</span><br><span class="line"><span class="built_in">console</span>.log([] == <span class="literal">false</span>);</span><br><span class="line"><span class="built_in">console</span>.log(![] == <span class="literal">false</span>);</span><br><span class="line"></span><br><span class="line">先重温：</span><br><span class="line"><span class="number">1.</span>基本数据类型：number string boolean <span class="literal">null</span> <span class="literal">undefined</span> symbol bigint</span><br><span class="line"><span class="number">2.</span>引用数据类型：object <span class="function"><span class="keyword">function</span></span></span><br><span class="line"><span class="function"></span></span><br><span class="line"><span class="function">解题：</span></span><br><span class="line"><span class="function">1.其他类型会转换为<span class="title">number</span>类型（对象先转换为<span class="title">string</span> -&gt; <span class="title">number</span>)</span></span><br><span class="line"><span class="function">- <span class="title">Number</span>(<span class="params">[val]</span>)</span></span><br><span class="line"><span class="function">- <span class="title">parseInt</span>(<span class="params">[val]</span>) <span class="title">parseFloat</span>(<span class="params">[val]</span>)</span></span><br><span class="line"><span class="function"></span></span><br><span class="line"><span class="function">2.隐式转换（浏览器内默认先转换为<span class="title">number</span>在进行计算）</span></span><br><span class="line"><span class="function">- <span class="title">isNaN</span>(<span class="params">[val]</span>)</span></span><br><span class="line"><span class="function">- 在+号左右的字符串被视为字符串拼接而不是运算符</span></span><br><span class="line"><span class="function"></span></span><br><span class="line"><span class="function">3.类型相同</span></span><br><span class="line"><span class="function">- </span>&#123;&#125; == &#123;&#125;  <span class="comment">// false ，因为对象比较是堆内存地址比较</span></span><br><span class="line">- [] == [] <span class="comment">// false</span></span><br><span class="line">- <span class="literal">NaN</span> == <span class="literal">NaN</span> <span class="comment">// false</span></span><br><span class="line"></span><br><span class="line"><span class="number">4.</span>类型不同</span><br><span class="line">- <span class="literal">null</span> == <span class="literal">undefined</span> <span class="comment">// true</span></span><br><span class="line">- <span class="literal">null</span> === <span class="literal">undefined</span> <span class="comment">// false</span></span><br><span class="line"><span class="literal">null</span>和<span class="literal">undefined</span>和其他都不等</span><br><span class="line">string == object，要把对象转换为字符串</span><br><span class="line">其余先转为number类型在进行比较</span><br><span class="line"></span><br><span class="line"><span class="keyword">let</span> result = <span class="number">100</span> + <span class="literal">true</span>(<span class="number">1</span>) + <span class="number">21.2</span> + <span class="literal">null</span>(<span class="number">0</span>) + <span class="literal">undefined</span>(<span class="literal">NaN</span>) + <span class="string">&quot;tencent&quot;</span> + [](<span class="string">&#x27;&#x27;</span>) + <span class="number">9</span> + <span class="literal">false</span>(<span class="string">&#x27;false&#x27;</span>)</span><br><span class="line"><span class="built_in">Number</span>(<span class="literal">undefined</span>) <span class="comment">// NaN</span></span><br><span class="line"></span><br><span class="line">[] == <span class="literal">false</span></span><br><span class="line"><span class="literal">true</span></span><br><span class="line">![] == <span class="literal">false</span></span><br><span class="line"><span class="literal">true</span></span><br><span class="line"></span><br><span class="line"><span class="built_in">console</span>.log([] == <span class="literal">false</span>);</span><br><span class="line"><span class="built_in">Number</span>([]) <span class="comment">// 0</span></span><br><span class="line"><span class="literal">false</span> <span class="comment">// 0</span></span><br><span class="line"><span class="number">0</span> == <span class="number">0</span> <span class="comment">// true</span></span><br><span class="line"></span><br><span class="line"><span class="built_in">console</span>.log(![] == <span class="literal">false</span>);</span><br><span class="line"><span class="comment">// 运算符优先级更高,!非 结果boolean</span></span><br><span class="line">![] <span class="comment">// false</span></span><br><span class="line"><span class="comment">// false、false类型相同</span></span><br><span class="line"><span class="literal">false</span> == <span class="literal">false</span> <span class="comment">// true</span></span><br></pre></td></tr></table></figure>

<p><strong>例二</strong>：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> a = ?</span><br><span class="line"><span class="keyword">if</span> (a == <span class="number">1</span> &amp;&amp; a == <span class="number">2</span> &amp;&amp; a == <span class="number">3</span>) &#123;</span><br><span class="line">  <span class="built_in">console</span>.log(<span class="number">1</span>)</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>解题</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>对象会隐式调用toString</span><br><span class="line"><span class="keyword">let</span> a = &#123;</span><br><span class="line">  i:<span class="number">0</span>,</span><br><span class="line">  <span class="function"><span class="title">toString</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">    <span class="keyword">return</span> ++<span class="built_in">this</span>.i</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="number">2.</span>方法会直接在一个对象上定义个新属性，或者修改一个对象的现有属性，并返回此对象</span><br><span class="line"><span class="keyword">let</span> i =<span class="number">0</span></span><br><span class="line"><span class="built_in">Object</span>.defineProperty(<span class="built_in">window</span>,<span class="string">&#x27;a&#x27;</span>,&#123;</span><br><span class="line">  <span class="function"><span class="title">get</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">    <span class="keyword">return</span> ++i;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>

<h2 id="3-操作符"><a href="#3-操作符" class="headerlink" title="3.操作符"></a>3.操作符</h2><p>描述一组用于操作数据值的操作符</p>
<ul>
<li>算术操作符</li>
<li>位操作符</li>
<li>关系操作符</li>
<li>相等操作符</li>
</ul>
<p><strong>3.1.一元操作符</strong></p>
<p>只能操作一个值的操作符</p>
<p>递增、递减操作符</p>
<ul>
<li><p>前置型</p>
</li>
<li><pre><code class="javascript">var age = 29;
age = age + 1 == ++age;

var age = 29;
var anotherAge = --age + 2;
alert(age); // 28
alert(anotherAge); // 30

// 只要是前缀操作符，变量的值都会在语句被求值之前改变（在计算机科学中，这通常被称为具有副作用）
// 因为前置递增和递减操作与执行语句的优先级相等，因此整个语句会从左到右被求值
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">&#96;&#96;&#96;&#96;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">- 后置型</span><br><span class="line"></span><br><span class="line">- &#96;&#96;&#96;javascript</span><br><span class="line">  &#x2F;&#x2F; 后缀版与前缀版的区别：后缀版递增和递减</span><br><span class="line">  var age &#x3D; 29;</span><br><span class="line">  age++;   &#x2F;&#x2F; 把递增操作符放在变量后面并不会改变语句的结果</span><br><span class="line"></span><br><span class="line">  var num1 &#x3D; 2;</span><br><span class="line">  var num2 &#x3D; 20;</span><br><span class="line">  var num3 &#x3D; num1-- + num2;  &#x2F;&#x2F; 22</span><br><span class="line">  var num4 &#x3D; num1 + num2;    &#x2F;&#x2F; 21</span><br><span class="line">&#96;&#96;&#96;&#96;</span><br><span class="line"></span><br><span class="line">- 隐式转换成 number</span><br><span class="line"></span><br><span class="line">- &#96;&#96;&#96;javascript</span><br><span class="line">  var s1 &#x3D; &quot;2&quot;;</span><br><span class="line">  var s2 &#x3D; &quot;z&quot;;</span><br><span class="line">  var b &#x3D; false;</span><br><span class="line">  var f &#x3D; 1.1;</span><br><span class="line">  var o &#x3D; &#123;</span><br><span class="line">    valueof: function () &#123;</span><br><span class="line">      return -1;</span><br><span class="line">    &#125;,</span><br><span class="line">  &#125;;</span><br><span class="line"></span><br><span class="line">  s1++; &#x2F;&#x2F; 3</span><br><span class="line">  s2++; &#x2F;&#x2F; NaN</span><br><span class="line">  b++; &#x2F;&#x2F; 1</span><br><span class="line">  f--; &#x2F;&#x2F; 0.10000000000009（由于浮点舍入错误所致）</span><br><span class="line">  o--; &#x2F;&#x2F; -2</span><br></pre></td></tr></table></figure>
</code></pre>
</li>
</ul>
<p><strong>3.2 一元加和减操作符</strong></p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> num = <span class="number">25</span>;</span><br><span class="line">num = +num; <span class="comment">// 25</span></span><br></pre></td></tr></table></figure>

<p>对非数值应用一元加操作符</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> s1 = <span class="string">&#x27;01&#x27;</span></span><br><span class="line"><span class="keyword">var</span> s2 = <span class="string">&#x27;1.1&#x27;</span></span><br><span class="line"><span class="keyword">var</span> s3 = <span class="string">&#x27;z&#x27;</span></span><br><span class="line"><span class="keyword">var</span> b = <span class="literal">false</span></span><br><span class="line"><span class="keyword">var</span> f = <span class="number">1.1</span></span><br><span class="line"><span class="keyword">var</span> o = &#123;</span><br><span class="line">  valueOf:<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">    <span class="keyword">return</span> -<span class="number">1</span></span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">s1 = +s1 <span class="comment">// 1</span></span><br><span class="line">s2 = +s2 <span class="comment">// 1.1</span></span><br><span class="line">s3 = +s3 <span class="comment">// NaN</span></span><br><span class="line">b = +b;  <span class="comment">// 0</span></span><br><span class="line">f = +f.  <span class="comment">// 1.1</span></span><br><span class="line">o = +o.  <span class="comment">// -1</span></span><br><span class="line"><span class="comment">// 要是 - 的话将转换为负数</span></span><br></pre></td></tr></table></figure>

<p><strong>3.3 位操作符</strong></p>
<p>按内存中表示数值的位来操作数值</p>
<p><strong>3.4 布尔操作符</strong></p>
<p>非（not）、与（and）、或（or）</p>
<p>1.逻辑非</p>
<p>无论什么数据类型，都将返回一个布尔值。效果就是：无论这个值是什么类型，先返回一个布尔值，然后对其取反</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">!<span class="literal">false</span>; <span class="comment">// true</span></span><br><span class="line">!<span class="string">&quot;blue&quot;</span>; <span class="comment">// false</span></span><br><span class="line">!<span class="number">0</span>; <span class="comment">// true</span></span><br><span class="line">!<span class="literal">NaN</span>; <span class="comment">// true</span></span><br><span class="line">!<span class="string">&quot;&quot;</span>; <span class="comment">// true</span></span><br><span class="line">!<span class="number">1234</span>; <span class="comment">// false</span></span><br><span class="line"><span class="comment">// 实际上会模拟Boolean（）转型函数的行为。</span></span><br></pre></td></tr></table></figure>

<p>2.逻辑与(&amp;&amp;)</p>
<p>从左到右，如果为 false 则返回</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> res = <span class="literal">true</span> &amp;&amp; <span class="literal">false</span>; <span class="comment">// false</span></span><br><span class="line"><span class="keyword">var</span> res = <span class="literal">false</span> &amp;&amp; <span class="literal">true</span>; <span class="comment">// false</span></span><br></pre></td></tr></table></figure>

<p>3.逻辑或(||)</p>
<p>从左到右只要遇到 true 就返回</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> res = <span class="literal">true</span> || <span class="literal">false</span>; <span class="comment">// true</span></span><br></pre></td></tr></table></figure>

<p><strong>3.5 关系运算符</strong></p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> res = <span class="number">5</span> &gt; <span class="number">3</span>; <span class="comment">// true</span></span><br><span class="line"><span class="keyword">var</span> res = <span class="number">5</span> &lt; <span class="number">3</span>; <span class="comment">// false</span></span><br><span class="line"><span class="keyword">var</span> res = <span class="string">&quot;Bob&quot;</span> &lt; <span class="string">&quot;aaaaaa&quot;</span>; <span class="comment">// true   B的字符编码为66。字母a的字符编码是97</span></span><br><span class="line"><span class="keyword">var</span> res = <span class="string">&quot;Bob&quot;</span>.toLowerCase() &lt; <span class="string">&quot;alphabet&quot;</span>.toLowerCase(); <span class="comment">// false</span></span><br><span class="line"><span class="keyword">var</span> res = <span class="string">&quot;23&quot;</span> &lt; <span class="string">&quot;3&quot;</span>; <span class="comment">// true.   “2”的编码是50。&quot;3&quot;的编码是51</span></span><br><span class="line"><span class="keyword">var</span> res = <span class="string">&quot;23&quot;</span> &lt; <span class="number">3</span>; <span class="comment">// false</span></span><br><span class="line"><span class="keyword">var</span> res = <span class="string">&quot;a&quot;</span> &lt; <span class="number">3</span>; <span class="comment">// false 因为&quot;a&quot;被转换成了NaN</span></span><br><span class="line"><span class="keyword">var</span> res = <span class="literal">NaN</span> &lt; <span class="number">3</span>; <span class="comment">// false</span></span><br><span class="line"><span class="keyword">var</span> res = <span class="literal">NaN</span> &gt;= <span class="number">3</span>; <span class="comment">// false.    任何数与NaN比较都是false</span></span><br></pre></td></tr></table></figure>

<p><strong>4.逗号操作符</strong></p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> num1 = <span class="number">1</span>,</span><br><span class="line">  num2 = <span class="number">2</span>,</span><br><span class="line">  num3 = <span class="number">3</span>; <span class="comment">// 逗号操作符声明了多个变量，但是除此之外，逗号操作符还可以用来赋值</span></span><br><span class="line"><span class="keyword">var</span> num = (<span class="number">5</span>, <span class="number">4</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">0</span>); <span class="comment">// num = 0 总会返回表达式中的最后一项</span></span><br></pre></td></tr></table></figure>

<h2 id="4-语句"><a href="#4-语句" class="headerlink" title="4.语句"></a>4.语句</h2><p>语句定义了 ECMAScript 中的主要语法，语句通常使用一或多个关键字来完成给定任务。</p>
<p><strong>4.1 if 语句</strong></p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">if</span> (condition) statement1 <span class="keyword">else</span> statement2</span><br></pre></td></tr></table></figure>

<p><strong>4.2 do-while 语句</strong></p>
<p>后测试循环语句，即只有在循环体中的代码执行之后，才会测试出口条件。在对条件表达式求值之前，循环体内的代码至少被执行一次</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> i = <span class="number">0</span>;</span><br><span class="line"><span class="keyword">do</span> &#123;</span><br><span class="line">  i += <span class="number">2</span>;</span><br><span class="line">&#125; <span class="keyword">while</span> (i &lt; <span class="number">10</span>);</span><br><span class="line">alert(i); <span class="comment">// 12</span></span><br></pre></td></tr></table></figure>

<p><strong>4.3 while 语句</strong></p>
<p>前测试循环语句，在循环体内的代码被执行之前，就会对出口条件求值</p>
<p><strong>4.4 for 语句</strong></p>
<p>前测试循环语句</p>
<p><strong>4.5 for-in 语句</strong></p>
<p>一种精准的迭代语句，可以用来枚举对象的属性。</p>
<p><strong>4.6 label 语句</strong></p>
<p>使用 label 语句可以在代码中添加标签</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line">label:statement</span><br><span class="line"></span><br><span class="line">start:<span class="keyword">for</span>(<span class="keyword">var</span> i = <span class="number">0</span>; i &lt; count; i++)&#123;</span><br><span class="line">  alert(i)</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">// 这个例子定义的start标签可以将来由break或continue引用</span></span><br><span class="line">举一个比较典型的例子，看完后即明白 Label 的应用：（未添加 Label）</span><br><span class="line">        <span class="keyword">var</span> num = <span class="number">0</span>;</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">0</span> ; i &lt; <span class="number">10</span> ; i++)&#123;</span><br><span class="line">             <span class="keyword">for</span> (<span class="keyword">var</span> j = <span class="number">0</span> ; j &lt; <span class="number">10</span> ; j++)&#123;</span><br><span class="line">                  <span class="keyword">if</span>( i == <span class="number">5</span> &amp;&amp; j == <span class="number">5</span> )&#123;</span><br><span class="line">                        <span class="keyword">break</span>;</span><br><span class="line">                  &#125;</span><br><span class="line">             num++;</span><br><span class="line">             &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        alert(num); <span class="comment">// 循环在 i 为5，j 为5的时候跳出 j循环，但会继续执行 i 循环，输出 95</span></span><br><span class="line"></span><br><span class="line">对比使用了 Label 之后的程序：（添加 Label 后）</span><br><span class="line">    <span class="keyword">var</span> num = <span class="number">0</span>;</span><br><span class="line">    outPoint:</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">0</span> ; i &lt; <span class="number">10</span> ; i++)&#123;</span><br><span class="line">         <span class="keyword">for</span> (<span class="keyword">var</span> j = <span class="number">0</span> ; j &lt; <span class="number">10</span> ; j++)&#123;</span><br><span class="line">              <span class="keyword">if</span>( i == <span class="number">5</span> &amp;&amp; j == <span class="number">5</span> )&#123;</span><br><span class="line">                    <span class="keyword">break</span> outPoint;</span><br><span class="line">              &#125;</span><br><span class="line">         num++;</span><br><span class="line">         &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    alert(num); <span class="comment">// 循环在 i 为5，j 为5的时候跳出双循环，返回到outPoint层继续执行，输出 55</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p><strong>4.7 break 和 continue 语句</strong></p>
<p>用于在循环中精确地控制代码的执行，break 会立即退出循环，强制执行循环后面的语句。而 continue 语句也是立即退出循环，但退出循环后会继续从循环的顶部继续执行</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> num = <span class="number">0</span>;</span><br><span class="line"><span class="keyword">for</span>(<span class="keyword">var</span> i =<span class="number">1</span>; i&lt;<span class="number">10</span>; i++)&#123;</span><br><span class="line">  <span class="keyword">if</span>(i % <span class="number">5</span> == <span class="number">0</span>)&#123;</span><br><span class="line">    <span class="keyword">break</span>;</span><br><span class="line">  &#125;</span><br><span class="line">  num++;</span><br><span class="line">&#125;</span><br><span class="line">alert(num)  <span class="comment">// 4</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">var</span> num = <span class="number">0</span>;</span><br><span class="line"><span class="keyword">for</span>(<span class="keyword">var</span> i =<span class="number">1</span>; i&lt;<span class="number">10</span>; i++)&#123;</span><br><span class="line">  <span class="keyword">if</span>(i % <span class="number">5</span> == <span class="number">0</span>)&#123;</span><br><span class="line">    <span class="keyword">continue</span>;</span><br><span class="line">  &#125;</span><br><span class="line">  num++;</span><br><span class="line">&#125;</span><br><span class="line">alert(num)  <span class="comment">// 8</span></span><br><span class="line">当变量等于i等于<span class="number">5</span>时，循环会在num再次递增之前退出，但接下来执行的是下一次循环，即i的值等于<span class="number">6</span>的循环。</span><br></pre></td></tr></table></figure>

<p><strong>4.8 with 语句</strong></p>
<p>with 语句的作用是将代码的作用域设置到一个特定的对象中。with 语法</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">with</span> (expression) statement;</span><br></pre></td></tr></table></figure>

<p>定义 with 语句的目的主要是为了简化多次编写同一个对象的工作</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> qs = location.search.substring(<span class="number">1</span>);</span><br><span class="line"><span class="keyword">var</span> hostName = location.hostname;</span><br><span class="line"><span class="keyword">var</span> url = location.href;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 使用 with语句可以改成</span></span><br><span class="line"><span class="keyword">with</span> (location) &#123;</span><br><span class="line">  <span class="keyword">var</span> qs = search.substring(<span class="number">1</span>);</span><br><span class="line">  <span class="keyword">var</span> hostname = hostname;</span><br><span class="line">  <span class="keyword">var</span> url = href;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>使用 with 语句关联了 location 对象，这意味着在 with 语句的代码块内部，每个变量首先被认为是一个局部变量，</p>
<p><strong>4.9 switch 语句</strong></p>
<p>流控制语句</p>
<p>switch 语句在比较值时使用的是全等操作符，因此不会发生类型转换</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">switch</span> (<span class="string">&quot;hello world&quot;</span>) &#123;</span><br><span class="line">  <span class="keyword">case</span> <span class="string">&quot;hello&quot;</span> + <span class="string">&quot;world&quot;</span>:</span><br><span class="line">    <span class="keyword">break</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>case 条件的值不需要是敞亮也可以是变量或表达式</p>
<p>switch 语句在比较每个条件的值时会使用全等操作符，因此不会强制的转换数据类型</p>
<h2 id="4-函数"><a href="#4-函数" class="headerlink" title="4.函数"></a>4.函数</h2><p>注意：只要碰到 return 语句，函数就会立即停止执行并退出。</p>
<p>严格模式下对函数的限制</p>
<ul>
<li><p>函数不能以 eval 或 arguments 作为名称</p>
</li>
<li><p>函数的参数不能叫 eval 或 arguments</p>
</li>
<li><p>两个命名参数不能拥有同一个名称</p>
</li>
</ul>
<p>小结：js 核心语言特性在 ECMA-262 中以伪语言 ECMAScript 的形式来定义。ECMAScript 包含所有基本语法、操作符、数据类型和对象，能完成基本的计算任务，但没有提供获得输入和产生输入的机制。理解 ECMAScript 复杂的细节是完全理解浏览器中 js 的关键。下面了解基本的 ECMAScript</p>
<ul>
<li>基本类型包括：undefined,null,boolean,number,string,symbol</li>
<li>与其他语言不通，ECMAScript 不区分整数和浮点值，只有 Number 一种数值数据类型</li>
<li>Object 是一种复杂数据类型，它是这门语言中所有对象的基类</li>
</ul>

    </div>

    
    
    
      <div>
          
            
<div class="my_post_copyright">
  <script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>
  
  <!-- JS库 sweetalert 可修改路径 -->
  <script src="https://cdn.bootcss.com/jquery/2.0.0/jquery.min.js"></script>
  <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
  <p><span>本文标题:</span><a href="/codeblog/2021/02/27/%E5%9F%BA%E6%9C%AC%E6%A6%82%E5%BF%B5/">Javascript基础（二）：javascript基本概念</a></p>
  <p><span>文章作者:</span><a href="/" title="访问  的个人博客"></a></p>
  <p><span>发布时间:</span>2021年02月27日 - 10:02</p>
  <p><span>最后更新:</span>2021年04月15日 - 09:04</p>
  <p><span>原始链接:</span><a href="/codeblog/2021/02/27/%E5%9F%BA%E6%9C%AC%E6%A6%82%E5%BF%B5/" title="Javascript基础（二）：javascript基本概念">http://skycoin.gitee.io/codeblog/2021/02/27/%E5%9F%BA%E6%9C%AC%E6%A6%82%E5%BF%B5/</a>
    <span class="copy-path"  title="点击复制文章链接"><i class="fa fa-clipboard" data-clipboard-text="http://skycoin.gitee.io/codeblog/2021/02/27/%E5%9F%BA%E6%9C%AC%E6%A6%82%E5%BF%B5/"  aria-label="复制成功！"></i></span>
  </p>
  <p><span>许可协议:</span><i class="fa fa-creative-commons"></i> 转载请保留原文链接及作者。</p>  
</div>
<script> 
    var clipboard = new Clipboard('.fa-clipboard');
    $(".fa-clipboard").click(function(){
      clipboard.on('success', function(){
        swal({   
          title: "",   
          text: '复制成功',
          icon: "success", 
          showConfirmButton: true
          });
    });
    });  
</script>



          
    </div>
        <div class="reward-container">
  <div>Donate comment here.</div>
  <button onclick="var qr = document.getElementById('qr'); qr.style.display = (qr.style.display === 'none') ? 'block' : 'none';">
    打赏
  </button>
  <div id="qr" style="display: none;">
      
      <div style="display: inline-block;">
        <img src="/codeblog/images/wechatpay.png" alt="若说 微信支付">
        <p>微信支付</p>
      </div>
      
      <div style="display: inline-block;">
        <img src="/codeblog/images/alipay.png" alt="若说 支付宝">
        <p>支付宝</p>
      </div>

  </div>
</div>

        

  <div class="followme">
    <p>欢迎关注我的其它发布渠道</p>

    <div class="social-list">

        <div class="social-item">
          <a target="_blank" class="social-link" href="/images/wechat_channel.jpg">
            <span class="icon">
              <i class="fab fa-weixin"></i>
            </span>

            <span class="label">WeChat</span>
          </a>
        </div>

        <div class="social-item">
          <a target="_blank" class="social-link" href="/atom.xml">
            <span class="icon">
              <i class="fa fa-rss"></i>
            </span>

            <span class="label">RSS</span>
          </a>
        </div>
    </div>
  </div>


      <footer class="post-footer">
          <div class="post-tags">
              <a href="/codeblog/tags/%E5%89%8D%E7%AB%AF/" rel="tag"># 前端</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/codeblog/2021/02/27/%E9%9B%86%E5%90%88%E5%BC%95%E7%94%A8%E7%B1%BB/" rel="prev" title="Javascript基础（五）：javascript集合引用类型">
      <i class="fa fa-chevron-left"></i> Javascript基础（五）：javascript集合引用类型
    </a></div>
      <div class="post-nav-item">
    <a href="/codeblog/2021/02/27/%E5%9F%BA%E6%9C%AC%E5%BC%95%E7%94%A8%E7%B1%BB%E5%9E%8B/" rel="next" title="Javascript基础（四）：javascript基本引用类型">
      Javascript基础（四）：javascript基本引用类型 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          
    <div class="comments" id="valine-comments"></div>

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E8%AF%AD%E6%B3%95"><span class="nav-number">1.</span> <span class="nav-text">1.语法</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B"><span class="nav-number">2.</span> <span class="nav-text">2.数据类型</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E6%93%8D%E4%BD%9C%E7%AC%A6"><span class="nav-number">3.</span> <span class="nav-text">3.操作符</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-%E8%AF%AD%E5%8F%A5"><span class="nav-number">4.</span> <span class="nav-text">4.语句</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-%E5%87%BD%E6%95%B0"><span class="nav-number">5.</span> <span class="nav-text">4.函数</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="若说"
      src="https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=4083356047,3551369852&fm=26&gp=0.jpg">
  <p class="site-author-name" itemprop="name">若说</p>
  <div class="site-description" itemprop="description">立志完成前端知识体系的架构</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/codeblog/archives/">
        
          <span class="site-state-item-count">5</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/codeblog/categories/">
          
        <span class="site-state-item-count">1</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">1</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/lovebxy" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;lovebxy" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="/codeblog/1490365616@qq.com" title="E-Mail → 1490365616@qq.com"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://weibo.com/yourname" title="Weibo → https:&#x2F;&#x2F;weibo.com&#x2F;yourname" rel="noopener" target="_blank"><i class="fab fa-weibo fa-fw"></i>Weibo</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://plus.google.com/yourname" title="Google → https:&#x2F;&#x2F;plus.google.com&#x2F;yourname" rel="noopener" target="_blank"><i class="fab fa-google fa-fw"></i>Google</a>
      </span>
  </div>


  <div class="links-of-blogroll motion-element">
    <div class="links-of-blogroll-title"><i class="fa fa-link fa-fw"></i>
      Links
    </div>
    <ul class="links-of-blogroll-list">
        <li class="links-of-blogroll-item">
          <a href="http://yoursite.com/" title="http:&#x2F;&#x2F;yoursite.com" rel="noopener" target="_blank">test</a>
        </li>
    </ul>
  </div>

      </div>
        <div class="back-to-top motion-element">
          <i class="fa fa-arrow-up"></i>
          <span>0%</span>
        </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">若说</span>
</div>

<div class="theme-info">
  <div class="powered-by"></div>
  <span class="post-count">博客全站共25.5k字</span>
</div>
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

<div class="powered-by">
  <i class="fa fa-user-md"></i>
  <span id="busuanzi_container_site_pv">
    本站访问量:<span id="busuanzi_value_site_pv"></span>次
  </span>
  <span class="post-meta-divider">|</span>
  <span id="busuanzi_container_site_uv">
    本站总访客量：<span id="busuanzi_value_site_uv"></span>人
  </span>
</div>

        








      </div>
    </footer>
  </div>

  
  <script src="/codeblog/lib/anime.min.js"></script>
  <script src="/codeblog/lib/velocity/velocity.min.js"></script>
  <script src="/codeblog/lib/velocity/velocity.ui.min.js"></script>

<script src="/codeblog/js/utils.js"></script>

<script src="/codeblog/js/motion.js"></script>


<script src="/codeblog/js/schemes/pisces.js"></script>


<script src="/codeblog/js/next-boot.js"></script>




  




  
<script src="/codeblog/js/local-search.js"></script>













  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : true,
      notify     : false,
      appId      : 'DbTfuJfplEWGguVvLyabTu99-gzGzoHsz',
      appKey     : 'hkLIIwmXwOd95taiLRxnUrjO',
      placeholder: "Just go go",
      avatar     : 'monsterid',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : true,
      lang       : '' || 'zh-cn',
      path       : location.pathname,
      recordIP   : false,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

  <script type="text/javascript" src="/js/src/clicklove.js"></script>
  <script type="text/javascript" src="//cdn.bootcss.com/canvas-nest.js/1.0.0/canvas-nest.min.js"></script>

</body>
</html>
